* Paddy Carter, Nicolas Van de Sijpe, and Raphael Calel, 13-June-2020
* Monte Carlo analysis for cross-country data


clear all
set more off
version 15.1


/* Set path to correct folder */ 
local DISK Nicolas // options: Nicolas, Paddy
if "`DISK'"=="Paddy" {
	cd "C:\Users\Paddy Carter\Dropbox\Development Finance Institutions\Country\Monte Carlo"
}
else if "`DISK'"=="Nicolas" {
	cd "C:\Users\ec1nv\Dropbox\My Documents\My Papers\Development Finance Institutions\Country\Monte Carlo"
}
else {
	di as error "Incorrect content for local DISK"
	exit
}


* We use gtools to speed up the MCs run by elusive: https://github.com/mcaceresb/stata-gtools


* Favour mata speed over space:
mata: mata set matafavor speed, perm
* run program
run elusive.do


capture log close
log using MCcheckOLSFE, replace text
*************************************************************************
* OLS AND FIXED EFFECTS
*************************************************************************
* first 6: zero additionality.
* 7-12: full additionality.
* 13-14: billions to trillions.
foreach num of numlist 1/14 {
	local reps = 1000

	* initial value of parameters used here:
	local noise = 0
	local dfilo = 2
	local dfihi = 1000
	local psmin = 2
	local mechanism random
	local btot = 1

		
	/* 1 = starting point: zero additionality, random selection, no noise in pc: */
	if `num' == 1 {

	}
	/* 2 = zero additionality, random selection, noise 0.5: */
	else if `num' == 2 {
		local noise = 0.5
	}
	/* 3 = zero additionality, random selection, noise 1: */
	else if `num' == 3 {
		local noise = 1
	}
	/* 4 = zero additionality, pclow selection mechanism, no noise in pc: */
	else if `num' == 4 {
		local mechanism pclow
	}
	/* 5 = zero additionality, pclow selection mechanism, noise 0.5: */
	else if `num' == 5 {
		local mechanism pclow
		local noise = 0.5
	}
	/* 6 = zero additionality, pclow selection mechanism, noise 1: */
	else if `num' == 6 {
		local mechanism pclow
		local noise = 1
	}
	/* 7 = full additionality, random selection mechanism, no noise in pc: */
	else if `num' == 7 {
		local dfilo = 0
		local dfihi = 2
		local psmin = 2
	}
	/* 8 = full additionality, random selection mechanism, noise 0.5: */
	else if `num' == 8 {
		local dfilo = 0
		local dfihi = 2
		local psmin = 2
		local noise = 0.5
	}
	/* 9 = full additionality, random selection mechanism, noise 1: */
	else if `num' == 9 {
		local dfilo = 0
		local dfihi = 2
		local psmin = 2
		local noise = 1
	}
	/* 10 = full additionality, pclow selection mechanism, no noise in pc: */
	else if `num' == 10 {
		local dfilo = 0
		local dfihi = 2
		local psmin = 2
		local mechanism pclow
	}
	/* 11 = full additionality, pclow selection mechanism, noise 0.5: */
	else if `num' == 11 {
		local dfilo = 0
		local dfihi = 2
		local psmin = 2
		local mechanism pclow
		local noise = 0.5
	}
	/* 12 = full additionality, pclow selection mechanism, noise 1: */
	else if `num' == 12 {
		local dfilo = 0
		local dfihi = 2
		local psmin = 2
		local mechanism pclow
		local noise = 1
	}
	/* 13 = full additionality, random selection mechanism, noise 0.5, btot = 3: */
	else if `num' == 13 {
		local dfilo = 0
		local dfihi = 2
		local psmin = 2
		local noise = 0.5
		local btot = 3
	}
	/* 14 = full additionality, pclow selection mechanism, noise 0.5, btot = 3: */
	else if `num' == 14 {
		local dfilo = 0
		local dfihi = 2
		local psmin = 2
		local mechanism pclow
		local noise = 0.5
		local btot = 3
	}


	simulate olsbetadfi=r(olsbetadfi) olsr2=r(olsr2) olspzeroadd=r(olspzeroadd) olspfulladd=r(olspfulladd) /// 
	olspcbetadfi=r(olspcbetadfi) olspcr2=r(olspcr2) olspcpzeroadd=r(olspcpzeroadd) olspcpfulladd=r(olspcpfulladd) ///
	olspcnodfir2=r(olspcnodfir2) olspcnodfinotdummiesr2=r(olspcnodfinotdummiesr2) ///
	febetadfi=r(febetadfi) fewr2=r(fewr2) fepzeroadd=r(fepzeroadd) fepfulladd=r(fepfulladd) /// 
	fepcbetadfi=r(fepcbetadfi) fepcwr2=r(fepcwr2) fepcpzeroadd=r(fepcpzeroadd) fepcpfulladd=r(fepcpfulladd) ///
	fepcnodfiwr2=r(fepcnodfiwr2) fepcnodfinotdummieswr2=r(fepcnodfinotdummieswr2) ///
	olsbetadfitrue=r(olsbetadfitrue) olsbetanumprojerover2=r(olsbetanumprojerover2) olsdelta=r(olsdelta) olsdeltapartialledout=r(olsdeltapartialledout) ///
	olsdeltadenom=r(olsdeltadenom) olsdeltanum=r(olsdeltanum) covnumprojver2DFIinv=r(covnumprojver2DFIinv) varDFIinv=r(varDFIinv) ///
	olspcbetadfitrue=r(olspcbetadfitrue) olspcbetanumprojerover2=r(olspcbetanumprojerover2) olspcbetapctrue=r(olspcbetapctrue) olspcdelta=r(olspcdelta) /// 
	olspcdeltapartialledout=r(olspcdeltapartialledout) olspcdeltadenom=r(olspcdeltadenom) olspcdeltanum=r(olspcdeltanum) /// 
	maxdbpercnumprojerover2=r(maxdbpercnumprojerover2) medinvDFIvsprivate=r(medinvDFIvsprivate), /// 
	saving(./Generated data/OLSFE`num'.dta, replace) reps(`reps') seed(150973): ///
	elusive, noise(`noise') mechanism(`mechanism') dfilo(`dfilo') dfihi(`dfihi') psmin(`psmin') estimator(OLSFE) transition(default) ///
	btot(`btot') extraGMM(no) dfibudget(default)
	
}
macro drop _all
log close


capture log close
log using MCcheckGMMzeroadd, replace text
*************************************************************************
* GMM WITH ZERO ADDITIONALITY
*************************************************************************
* Zero additionality, random selection mechanism
foreach num of numlist 1/9 {
	local reps = 1000

	*  initial values of parameters used here:
	local noise = 0
	local drift = 0
	local mu1 = 0
	local mu2 = 2
	local mu3 = 4
	local transition default
	local extraGMM yes
	local sigma = 0.15


	/* 1 = starting point, no noise: */
	if `num' == 1 {

	}
	/* 2 = noise = 0.5: */
	else if `num' == 2 {
		local noise = 0.5
	}
	/* 3 = noise = 1: */
	else if `num' == 3 {
		local noise = 1
	}
	/* 4 = : mean pc closer together, noise 0.5 */
	if `num' == 4 {
		local mu1 = 1
		local mu2 = 2
		local mu3 = 3
		local extraGMM no
		local noise = 0.5
	}
	/* 5 = mean pc the same, noise 0.5: */
	if `num' == 5 {
		local mu1 = 2
		local mu2 = 2
		local mu3 = 2
		local extraGMM no
		local noise = 0.5
	}
	/* 6 = upward drift in budget, noise 0.5: */
	if `num' == 6 {
		local drift = 0.05
		local sigma = 0
		local extraGMM no
		local noise = 0.5
	}
	/* 7 = types fixed, noise 0.5: */
	if `num' == 7 {
		local transition fixedtypes
		local extraGMM no
		local noise = 0.5
	}
	/* 8 = types fixed, upward drift in budget, noise 0.5: */
	if `num' == 8 {
		local transition fixedtypes
		local drift = 0.05
		local sigma = 0
		local extraGMM no
		local noise = 0.5
	}
	/* 9 = types fixed, downward drift in budget, noise 0.5: */
	if `num' == 9 {
		local transition fixedtypes
		local drift = -0.05
		local sigma = 0
		local extraGMM no
		local noise = 0.5
	}

	
	simulate betadfi1=r(betadfi1) numinstr1=r(numinstr1) m1p1=r(m1p1) m11=r(m11) m2p1=r(m2p1) ///
	hansp1=r(hansp1) sargp1=r(sargp1) /// 
	pzeroadd1=r(pzeroadd1) pfulladd1=r(pfulladd1) condFDFI1=r(condFDFI1) condFDFIp1=r(condFDFIp1) ///
	betadfiwpc1=r(betadfiwpc1) numinstrwpc1=r(numinstrwpc1) m1pwpc1=r(m1pwpc1) m1wpc1=r(m1wpc1) m2pwpc1=r(m2pwpc1) ///
	hanspwpc1=r(hanspwpc1) sargpwpc1=r(sargpwpc1) diffHp_DFIinvdiffwpc1=r(diffHp_DFIinvdiffwpc1) diffHp_DFIinvlevwpc1=r(diffHp_DFIinvlevwpc1) /// 
	pzeroaddwpc1=r(pzeroaddwpc1) pfulladdwpc1=r(pfulladdwpc1) condFDFIwpc1=r(condFDFIwpc1) condFDFIpwpc1=r(condFDFIpwpc1) ///
	betadfi2=r(betadfi2) betalagdep2=r(betalagdep2) numinstr2=r(numinstr2) m1p2=r(m1p2) m12=r(m12) m2p2=r(m2p2) ///
	hansp2=r(hansp2) sargp2=r(sargp2) ///
	diffHp_DFIinvdiff2=r(diffHp_DFIinvdiff2) diffHp_DFIinvlev2=r(diffHp_DFIinvlev2) /// 
	pzeroadd2=r(pzeroadd2) pfulladd2=r(pfulladd2) condFDFI2=r(condFDFI2) condFDFIp2=r(condFDFIp2) ///
	betadfiwpc2=r(betadfiwpc2) betalagdepwpc2=r(betalagdepwpc2) numinstrwpc2=r(numinstrwpc2) m1pwpc2=r(m1pwpc2) m1wpc2=r(m1wpc2) m2pwpc2=r(m2pwpc2) ///
	hanspwpc2=r(hanspwpc2) sargpwpc2=r(sargpwpc2) ///
	diffHp_lagdepwpc2=r(diffHp_lagdepwpc2) diffHp_DFIinvdiffwpc2=r(diffHp_DFIinvdiffwpc2) diffHp_DFIinvlevwpc2=r(diffHp_DFIinvlevwpc2) diffHp_pc2=r(diffHp_pc2) /// 
	pzeroaddwpc2=r(pzeroaddwpc2) pfulladdwpc2=r(pfulladdwpc2) condFDFIwpc2=r(condFDFIwpc2) condFDFIpwpc2=r(condFDFIpwpc2) ///
	betadfi3=r(betadfi3) numinstr3=r(numinstr3) m1p3=r(m1p3) m13=r(m13) m2p3=r(m2p3) ///
	hansp3=r(hansp3) sargp3=r(sargp3) diffHp_lev3=r(diffHp_lev3) diffHp_DFIinvlev3=r(diffHp_DFIinvlev3) /// 
	pzeroadd3=r(pzeroadd3) pfulladd3=r(pfulladd3) condFDFI3=r(condFDFI3) condFDFIp3=r(condFDFIp3) ///
	betadfiwpc3=r(betadfiwpc3) numinstrwpc3=r(numinstrwpc3) m1pwpc3=r(m1pwpc3) m1wpc3=r(m1wpc3) m2pwpc3=r(m2pwpc3) ///
	hanspwpc3=r(hanspwpc3) sargpwpc3=r(sargpwpc3) diffHp_levwpc3=r(diffHp_levwpc3) diffHp_DFIinvdiffwpc3=r(diffHp_DFIinvdiffwpc3) ///
	diffHp_DFIinvlevwpc3=r(diffHp_DFIinvlevwpc3) diffHp_pc3=r(diffHp_pc3) ///
	pzeroaddwpc3=r(pzeroaddwpc3) pfulladdwpc3=r(pfulladdwpc3) condFDFIwpc3=r(condFDFIwpc3) condFDFIpwpc3=r(condFDFIpwpc3) ///
	betadfi4=r(betadfi4) betalagdep4=r(betalagdep4) numinstr4=r(numinstr4) m1p4=r(m1p4) m14=r(m14) m2p4=r(m2p4) ///
	hansp4=r(hansp4) sargp4=r(sargp4) diffHp_lev4=r(diffHp_lev4) diffHp_lagdep4=r(diffHp_lagdep4) ///
	diffHp_DFIinvdiff4=r(diffHp_DFIinvdiff4) diffHp_DFIinvlev4=r(diffHp_DFIinvlev4) /// 
	pzeroadd4=r(pzeroadd4) pfulladd4=r(pfulladd4) condFDFI4=r(condFDFI4) condFDFIp4=r(condFDFIp4) ///
	betadfiwpc4=r(betadfiwpc4) betalagdepwpc4=r(betalagdepwpc4) numinstrwpc4=r(numinstrwpc4) m1pwpc4=r(m1pwpc4) m1wpc4=r(m1wpc4) m2pwpc4=r(m2pwpc4) ///
	hanspwpc4=r(hanspwpc4) sargpwpc4=r(sargpwpc4) diffHp_levwpc4=r(diffHp_levwpc4) diffHp_lagdepwpc4=r(diffHp_lagdepwpc4) ///
	diffHp_DFIinvdiffwpc4=r(diffHp_DFIinvdiffwpc4) diffHp_DFIinvlevwpc4=r(diffHp_DFIinvlevwpc4) diffHp_pc4=r(diffHp_pc4) /// 
	pzeroaddwpc4=r(pzeroaddwpc4) pfulladdwpc4=r(pfulladdwpc4) condFDFIwpc4=r(condFDFIwpc4) condFDFIpwpc4=r(condFDFIpwpc4) ///
	betadfi5=r(betadfi5) numinstr5=r(numinstr5) m1p5=r(m1p5) m15=r(m15) m2p5=r(m2p5) ///
	pzeroadd5=r(pzeroadd5) pfulladd5=r(pfulladd5) condFDFI5=r(condFDFI5) condFDFIp5=r(condFDFIp5) ///
	betadfiwpc5=r(betadfiwpc5) numinstrwpc5=r(numinstrwpc5) m1pwpc5=r(m1pwpc5) m1wpc5=r(m1wpc5) m2pwpc5=r(m2pwpc5) ///
	pzeroaddwpc5=r(pzeroaddwpc5) pfulladdwpc5=r(pfulladdwpc5) condFDFIwpc5=r(condFDFIwpc5) condFDFIpwpc5=r(condFDFIpwpc5) ///
	betadfi6=r(betadfi6) pzeroadd6=r(pzeroadd6) pfulladd6=r(pfulladd6) FSrobustF6=r(FSrobustF6) FSbetaL2DFI6=r(FSbetaL2DFI6) OVbetaL2DFI6=r(OVbetaL2DFI6) ///
	corrL2DFIu6=r(corrL2DFIu6) corrL2DFIx6=r(corrL2DFIx6) ///
	sdu6=r(sdu6) sdx6=r(sdx6) ///
	betadfiwpc6=r(betadfiwpc6) pzeroaddwpc6=r(pzeroaddwpc6) pfulladdwpc6=r(pfulladdwpc6) FSrobustFwpc6=r(FSrobustFwpc6) FSbetaL2DFIwpc6=r(FSbetaL2DFIwpc6) FSbetaL2pc6=r(FSbetaL2pc6) ///
	OVbetaL2DFIwpc6=r(OVbetaL2DFIwpc6) OVbetaL2pc6=r(OVbetaL2pc6) ///
	betadfi7=r(betadfi7) numinstr7=r(numinstr7) m1p7=r(m1p7) m17=r(m17) m2p7=r(m2p7) ///
	pzeroadd7=r(pzeroadd7) pfulladd7=r(pfulladd7) condFDFI7=r(condFDFI7) condFDFIp7=r(condFDFIp7) ///
	betadfiwpc7=r(betadfiwpc7) numinstrwpc7=r(numinstrwpc7) m1pwpc7=r(m1pwpc7) m1wpc7=r(m1wpc7) m2pwpc7=r(m2pwpc7) ///
	pzeroaddwpc7=r(pzeroaddwpc7) pfulladdwpc7=r(pfulladdwpc7) condFDFIwpc7=r(condFDFIwpc7) condFDFIpwpc7=r(condFDFIpwpc7) ///
	betadfi8=r(betadfi8) pzeroadd8=r(pzeroadd8) pfulladd8=r(pfulladd8) FSrobustF8=r(FSrobustF8) FSbetaDLDFI8=r(FSbetaDLDFI8) OVbetaDLDFI8=r(OVbetaDLDFI8) ///
	corrDLDFIu8=r(corrDLDFIu8) corrDLDFIx8=r(corrDLDFIx8) ///
	sdu8=r(sdu8) sdx8=r(sdx8) ///
	betadfiwpc8=r(betadfiwpc8) pzeroaddwpc8=r(pzeroaddwpc8) pfulladdwpc8=r(pfulladdwpc8) FSrobustFwpc8=r(FSrobustFwpc8) FSbetaDLDFIwpc8=r(FSbetaDLDFIwpc8) FSbetaDLpc8=r(FSbetaDLpc8) ///
	OVbetaDLDFIwpc8=r(OVbetaDLDFIwpc8) OVbetaDLpc8=r(OVbetaDLpc8) ///	
	maxdbpercnumprojerover2=r(maxdbpercnumprojerover2) finaldb=r(finaldb) finalnumprojerover2=r(finalnumprojerover2) medinvDFIvsprivate=r(medinvDFIvsprivate) ///
	, saving(./Generated data/GMMzeroadd`num'.dta, replace) reps(`reps') seed(150973): elusive, noise(`noise') estimator(GMM) mechanism(random) transition(`transition') ///
	drift(`drift') mu1(`mu1') mu2(`mu2') mu3(`mu3') extraGMM(`extraGMM') sigma(`sigma') dfibudget(default)
}
macro drop _all
log close


capture log close
log using MCcheckGMMfulladd, replace text
*************************************************************************
* GMM WITH FULL ADDITIONALITY
*************************************************************************
* Full additionality, random selection mechanism
foreach num of numlist 1/9 {
	local reps = 1000

	*  initial values of parameters used here:
	local noise = 0
	local drift = 0
	local mu1 = 0
	local mu2 = 2
	local mu3 = 4
	local transition default
	local extraGMM yes
	local sigma = 0.15
	local dfilo = 0 
	local dfihi = 2


	/* 1 = starting point, no noise: */
	if `num' == 1 {

	}
	/* 2 = noise = 0.5: */
	else if `num' == 2 {
		local noise = 0.5
	}
	/* 3 = noise = 1: */
	else if `num' == 3 {
		local noise = 1
	}
	/* 4 = : mean pc closer together, noise 0.5 */
	if `num' == 4 {
		local mu1 = 1
		local mu2 = 2
		local mu3 = 3
		local extraGMM no
		local noise = 0.5
	}
	/* 5 = mean pc the same, noise 0.5: */
	if `num' == 5 {
		local mu1 = 2
		local mu2 = 2
		local mu3 = 2
		local extraGMM no
		local noise = 0.5
	}
	/* 6 = upward drift in budget, noise 0.5: */
	if `num' == 6 {
		local drift = 0.05
		local sigma = 0
		local extraGMM no
		local noise = 0.5
	}
	/* 7 = types fixed, noise 0.5: */
	if `num' == 7 {
		local transition fixedtypes
		local extraGMM no
		local noise = 0.5
	}
	/* 8 = types fixed, upward drift in budget, noise 0.5: */
	if `num' == 8 {
		local transition fixedtypes
		local drift = 0.05
		local sigma = 0
		local extraGMM no
		local noise = 0.5
	}
	/* 9 = types fixed, downward drift in budget, noise 0.5: */
	if `num' == 9 {
		local transition fixedtypes
		local drift = -0.05
		local sigma = 0
		local extraGMM no
		local noise = 0.5
	}

	
	simulate betadfi1=r(betadfi1) numinstr1=r(numinstr1) m1p1=r(m1p1) m11=r(m11) m2p1=r(m2p1) ///
	hansp1=r(hansp1) sargp1=r(sargp1) /// 
	pzeroadd1=r(pzeroadd1) pfulladd1=r(pfulladd1) condFDFI1=r(condFDFI1) condFDFIp1=r(condFDFIp1) ///
	betadfiwpc1=r(betadfiwpc1) numinstrwpc1=r(numinstrwpc1) m1pwpc1=r(m1pwpc1) m1wpc1=r(m1wpc1) m2pwpc1=r(m2pwpc1) ///
	hanspwpc1=r(hanspwpc1) sargpwpc1=r(sargpwpc1) diffHp_DFIinvdiffwpc1=r(diffHp_DFIinvdiffwpc1) diffHp_DFIinvlevwpc1=r(diffHp_DFIinvlevwpc1) /// 
	pzeroaddwpc1=r(pzeroaddwpc1) pfulladdwpc1=r(pfulladdwpc1) condFDFIwpc1=r(condFDFIwpc1) condFDFIpwpc1=r(condFDFIpwpc1) ///
	betadfi2=r(betadfi2) betalagdep2=r(betalagdep2) numinstr2=r(numinstr2) m1p2=r(m1p2) m12=r(m12) m2p2=r(m2p2) ///
	hansp2=r(hansp2) sargp2=r(sargp2) ///
	diffHp_DFIinvdiff2=r(diffHp_DFIinvdiff2) diffHp_DFIinvlev2=r(diffHp_DFIinvlev2) /// 
	pzeroadd2=r(pzeroadd2) pfulladd2=r(pfulladd2) condFDFI2=r(condFDFI2) condFDFIp2=r(condFDFIp2) ///
	betadfiwpc2=r(betadfiwpc2) betalagdepwpc2=r(betalagdepwpc2) numinstrwpc2=r(numinstrwpc2) m1pwpc2=r(m1pwpc2) m1wpc2=r(m1wpc2) m2pwpc2=r(m2pwpc2) ///
	hanspwpc2=r(hanspwpc2) sargpwpc2=r(sargpwpc2) ///
	diffHp_lagdepwpc2=r(diffHp_lagdepwpc2) diffHp_DFIinvdiffwpc2=r(diffHp_DFIinvdiffwpc2) diffHp_DFIinvlevwpc2=r(diffHp_DFIinvlevwpc2) diffHp_pc2=r(diffHp_pc2) /// 
	pzeroaddwpc2=r(pzeroaddwpc2) pfulladdwpc2=r(pfulladdwpc2) condFDFIwpc2=r(condFDFIwpc2) condFDFIpwpc2=r(condFDFIpwpc2) ///
	betadfi3=r(betadfi3) numinstr3=r(numinstr3) m1p3=r(m1p3) m13=r(m13) m2p3=r(m2p3) ///
	hansp3=r(hansp3) sargp3=r(sargp3) diffHp_lev3=r(diffHp_lev3) diffHp_DFIinvlev3=r(diffHp_DFIinvlev3) /// 
	pzeroadd3=r(pzeroadd3) pfulladd3=r(pfulladd3) condFDFI3=r(condFDFI3) condFDFIp3=r(condFDFIp3) ///
	betadfiwpc3=r(betadfiwpc3) numinstrwpc3=r(numinstrwpc3) m1pwpc3=r(m1pwpc3) m1wpc3=r(m1wpc3) m2pwpc3=r(m2pwpc3) ///
	hanspwpc3=r(hanspwpc3) sargpwpc3=r(sargpwpc3) diffHp_levwpc3=r(diffHp_levwpc3) diffHp_DFIinvdiffwpc3=r(diffHp_DFIinvdiffwpc3) ///
	diffHp_DFIinvlevwpc3=r(diffHp_DFIinvlevwpc3) diffHp_pc3=r(diffHp_pc3) ///
	pzeroaddwpc3=r(pzeroaddwpc3) pfulladdwpc3=r(pfulladdwpc3) condFDFIwpc3=r(condFDFIwpc3) condFDFIpwpc3=r(condFDFIpwpc3) ///
	betadfi4=r(betadfi4) betalagdep4=r(betalagdep4) numinstr4=r(numinstr4) m1p4=r(m1p4) m14=r(m14) m2p4=r(m2p4) ///
	hansp4=r(hansp4) sargp4=r(sargp4) diffHp_lev4=r(diffHp_lev4) diffHp_lagdep4=r(diffHp_lagdep4) ///
	diffHp_DFIinvdiff4=r(diffHp_DFIinvdiff4) diffHp_DFIinvlev4=r(diffHp_DFIinvlev4) /// 
	pzeroadd4=r(pzeroadd4) pfulladd4=r(pfulladd4) condFDFI4=r(condFDFI4) condFDFIp4=r(condFDFIp4) ///
	betadfiwpc4=r(betadfiwpc4) betalagdepwpc4=r(betalagdepwpc4) numinstrwpc4=r(numinstrwpc4) m1pwpc4=r(m1pwpc4) m1wpc4=r(m1wpc4) m2pwpc4=r(m2pwpc4) ///
	hanspwpc4=r(hanspwpc4) sargpwpc4=r(sargpwpc4) diffHp_levwpc4=r(diffHp_levwpc4) diffHp_lagdepwpc4=r(diffHp_lagdepwpc4) ///
	diffHp_DFIinvdiffwpc4=r(diffHp_DFIinvdiffwpc4) diffHp_DFIinvlevwpc4=r(diffHp_DFIinvlevwpc4) diffHp_pc4=r(diffHp_pc4) /// 
	pzeroaddwpc4=r(pzeroaddwpc4) pfulladdwpc4=r(pfulladdwpc4) condFDFIwpc4=r(condFDFIwpc4) condFDFIpwpc4=r(condFDFIpwpc4) ///
	betadfi5=r(betadfi5) numinstr5=r(numinstr5) m1p5=r(m1p5) m15=r(m15) m2p5=r(m2p5) ///
	pzeroadd5=r(pzeroadd5) pfulladd5=r(pfulladd5) condFDFI5=r(condFDFI5) condFDFIp5=r(condFDFIp5) ///
	betadfiwpc5=r(betadfiwpc5) numinstrwpc5=r(numinstrwpc5) m1pwpc5=r(m1pwpc5) m1wpc5=r(m1wpc5) m2pwpc5=r(m2pwpc5) ///
	pzeroaddwpc5=r(pzeroaddwpc5) pfulladdwpc5=r(pfulladdwpc5) condFDFIwpc5=r(condFDFIwpc5) condFDFIpwpc5=r(condFDFIpwpc5) ///
	betadfi6=r(betadfi6) pzeroadd6=r(pzeroadd6) pfulladd6=r(pfulladd6) FSrobustF6=r(FSrobustF6) FSbetaL2DFI6=r(FSbetaL2DFI6) OVbetaL2DFI6=r(OVbetaL2DFI6) ///
	corrL2DFIu6=r(corrL2DFIu6) corrL2DFIx6=r(corrL2DFIx6) ///
	sdu6=r(sdu6) sdx6=r(sdx6) ///
	betadfiwpc6=r(betadfiwpc6) pzeroaddwpc6=r(pzeroaddwpc6) pfulladdwpc6=r(pfulladdwpc6) FSrobustFwpc6=r(FSrobustFwpc6) FSbetaL2DFIwpc6=r(FSbetaL2DFIwpc6) FSbetaL2pc6=r(FSbetaL2pc6) ///
	OVbetaL2DFIwpc6=r(OVbetaL2DFIwpc6) OVbetaL2pc6=r(OVbetaL2pc6) ///
	betadfi7=r(betadfi7) numinstr7=r(numinstr7) m1p7=r(m1p7) m17=r(m17) m2p7=r(m2p7) ///
	pzeroadd7=r(pzeroadd7) pfulladd7=r(pfulladd7) condFDFI7=r(condFDFI7) condFDFIp7=r(condFDFIp7) ///
	betadfiwpc7=r(betadfiwpc7) numinstrwpc7=r(numinstrwpc7) m1pwpc7=r(m1pwpc7) m1wpc7=r(m1wpc7) m2pwpc7=r(m2pwpc7) ///
	pzeroaddwpc7=r(pzeroaddwpc7) pfulladdwpc7=r(pfulladdwpc7) condFDFIwpc7=r(condFDFIwpc7) condFDFIpwpc7=r(condFDFIpwpc7) ///
	betadfi8=r(betadfi8) pzeroadd8=r(pzeroadd8) pfulladd8=r(pfulladd8) FSrobustF8=r(FSrobustF8) FSbetaDLDFI8=r(FSbetaDLDFI8) OVbetaDLDFI8=r(OVbetaDLDFI8) ///
	corrDLDFIu8=r(corrDLDFIu8) corrDLDFIx8=r(corrDLDFIx8) ///
	sdu8=r(sdu8) sdx8=r(sdx8) ///
	betadfiwpc8=r(betadfiwpc8) pzeroaddwpc8=r(pzeroaddwpc8) pfulladdwpc8=r(pfulladdwpc8) FSrobustFwpc8=r(FSrobustFwpc8) FSbetaDLDFIwpc8=r(FSbetaDLDFIwpc8) FSbetaDLpc8=r(FSbetaDLpc8) ///
	OVbetaDLDFIwpc8=r(OVbetaDLDFIwpc8) OVbetaDLpc8=r(OVbetaDLpc8) ///	
	maxdbpercnumprojerover2=r(maxdbpercnumprojerover2) finaldb=r(finaldb) finalnumprojerover2=r(finalnumprojerover2)  medinvDFIvsprivate=r(medinvDFIvsprivate) ///
	, saving(./Generated data/GMMfulladd`num'.dta, replace) reps(`reps') seed(150973): elusive, noise(`noise') estimator(GMM) mechanism(random) transition(`transition') ///
	drift(`drift') mu1(`mu1') mu2(`mu2') mu3(`mu3') extraGMM(`extraGMM') sigma(`sigma') dfilo(`dfilo') dfihi(`dfihi') dfibudget(default)
}
macro drop _all
log close


capture log close
log using MCcheckIVzeroadd, replace text
*************************************************************************
* SUPPLY-PUSH IV WITH ZERO ADDITIONALITY
*************************************************************************
foreach num of numlist 1/14 {
	local reps = 1000
	
	* local defaults
	local noise = 0.5
	local phi = 0
	local transition default
	local sigma = 0.15
	local drift = 0
	local nD = 3
	
	
	/* 1 = default, noise 0.5 in pc: */
	if `num' == 1 {

	}
	/* 2 = fewertransitions, noise 0.5 in pc: */
	else if `num' == 2 {
		local transition fewertransitions
	}
	/* 3 = oneperiodchange, noise 0.5 in pc: */
	else if `num' == 3 {
		local transition oneperiodchange
	}
	/* 4 = fixedtypes, noise 0.5 in pc: */
	else if `num' == 4 {
		local transition fixedtypes
	}
	/* 5 = phi = 1, noise 0.5 in pc: */
	if `num' == 5 {
		local phi = 1
		local transition oneperiodchange
	}
	/* 6 = phi = 2, noise 0.5 in pc: */
	else if `num' == 6 {
		local phi = 2
		local transition oneperiodchange
	}
	/* 7 = sigma = 0.05, phi = 2, noise 0.5 in pc: */
	else if `num' == 7 {
		local sigma = 0.05
		local phi = 2
		local transition oneperiodchange
	}
	/* 8 = sigma = 0.05, phi = 2, noise 1 in pc: */
	else if `num' == 8 {
		local sigma = 0.05
		local phi = 2
		local noise = 1
		local transition oneperiodchange
	}
	/* 9 = default, noise 0.5 in pc, downward drift: */
	else if `num' == 9 {
		local transition default
		local sigma = 0
		local drift = -0.1
	}
	/* 10 = fewertransitions, noise 0.5 in pc, downward drift: */
	else if `num' == 10 {
		local transition fewertransitions
		local sigma = 0
		local drift = -0.1
	}
	/* 11 = fixedtypes, noise 0.5 in pc, downward drift: */
	else if `num' == 11 {
		local transition fixedtypes
		local sigma = 0
		local drift = -0.1
	}
	/* 12 = default, noise 0.5 in pc, upward drift: */
	else if `num' == 12 {
		local transition default
		local sigma = 0
		local drift = 0.05
	}
	/* 13 = fewertransitions, noise 0.5 in pc, upward drift: */
	else if `num' == 13 {
		local transition fewertransitions
		local sigma = 0
		local drift = 0.05
	}
	/* 14 = fixedtypes, noise 0.5 in pc, upward drift: */
	else if `num' == 14 {
		local transition fixedtypes
		local sigma = 0
		local drift = 0.05
	}

	
	simulate ivbetadfi=r(ivbetadfi) ivsedfi=r(ivsedfi) underid=r(underid) underidp=r(underidp) weakid=r(weakid) ///
	ivpzeroadd=r(ivpzeroadd) ivpfulladd=r(ivpfulladd) ivFSbeta=r(ivFSbeta) ivFSse=r(ivFSse) ivRFbeta=r(ivRFbeta) ivRFse=r(ivRFse) febetadfi=r(febetadfi) ///
	ivbetadfil1out=r(ivbetadfil1out) ivsedfil1out=r(ivsedfil1out) underidl1out=r(underidl1out) underidpl1out=r(underidpl1out) /// 
	weakidl1out=r(weakidl1out) ivpzeroaddl1out=r(ivpzeroaddl1out) ivpfulladdl1out=r(ivpfulladdl1out) ///
	ivbetadfict=r(ivbetadfict) ivsedfict=r(ivsedfict) underidct=r(underidct) underidpct=r(underidpct) weakidct=r(weakidct) ///
	ivpzeroaddct=r(ivpzeroaddct) ivpfulladdct=r(ivpfulladdct) ivFSbetact=r(ivFSbetact) ivFSsect=r(ivFSsect) ivRFbetact=r(ivRFbetact) ivRFsect=r(ivRFsect) ///
	ivpcbetadfi=r(ivpcbetadfi) ivpcsedfi=r(ivpcsedfi) underidpc=r(underidpc) underidppc=r(underidppc) weakidpc=r(weakidpc) ///
	ivpcpzeroadd=r(ivpcpzeroadd) ivpcpfulladd=r(ivpcpfulladd) ivpcFSbeta=r(ivpcFSbeta) ivpcFSse=r(ivpcFSse) ivpcRFbeta=r(ivpcRFbeta) ivpcRFse=r(ivpcRFse) fepcbetadfi=r(fepcbetadfi) ///
	ivpcbetadfil1out=r(ivpcbetadfil1out) ivpcsedfil1out=r(ivpcsedfil1out) underidpcl1out=r(underidpcl1out) underidppcl1out=r(underidppcl1out) /// 
	weakidpcl1out=r(weakidpcl1out) ivpcpzeroaddl1out=r(ivpcpzeroaddl1out) ivpcpfulladdl1out=r(ivpcpfulladdl1out) ///	
	ivbetadfitrue=r(ivbetadfitrue) ivbetanumprojerover2=r(ivbetanumprojerover2) covzu=r(covzu) covzx=r(covzx) /// 
	ivpcbetadfitrue=r(ivpcbetadfitrue) ivpcbetanumprojerover2=r(ivpcbetanumprojerover2) ivpcbetapctrue=r(ivpcbetapctrue) pccovzu=r(pccovzu) pccovzx=r(pccovzx) ///
	mindbpercnumprojerover2=r(mindbpercnumprojerover2) maxdbpercnumprojerover2=r(maxdbpercnumprojerover2) varz=r(varz) pcvarz=r(pcvarz) ///
	corrzu=r(corrzu) corrzx=r(corrzx) sdu=r(sdu) sdx=r(sdx) pccorrzu=r(pccorrzu) pccorrzx=r(pccorrzx) pcsdu=r(pcsdu) pcsdx=r(pcsdx) ///
	finaldb=r(finaldb) finalnumprojerover2=r(finalnumprojerover2)  medinvDFIvsprivate=r(medinvDFIvsprivate) /// 
	type1invy1=r(type1invy1) type1invy20=r(type1invy20) type2invy1=r(type2invy1) type2invy20=r(type2invy20) type3invy1=r(type3invy1) type3invy20=r(type3invy20) ///
	type1dfiinvy1=r(type1dfiinvy1) type1dfiinvy20=r(type1dfiinvy20) type2dfiinvy1=r(type2dfiinvy1) type2dfiinvy20=r(type2dfiinvy20) type3dfiinvy1=r(type3dfiinvy1) type3dfiinvy20=r(type3dfiinvy20) ///
	type1dfiinvIVy1=r(type1dfiinvIVy1) type1dfiinvIVy20=r(type1dfiinvIVy20) type2dfiinvIVy1=r(type2dfiinvIVy1) type2dfiinvIVy20=r(type2dfiinvIVy20) type3dfiinvIVy1=r(type3dfiinvIVy1) type3dfiinvIVy20=r(type3dfiinvIVy20), /// 
	saving(./Generated data/IVzeroadd`num'.dta, replace) reps(`reps') seed(150973): /// 
	elusive, noise(`noise') phi(`phi') estimator(IV) mechanism(random) transition(`transition') /// 
	sigma(`sigma') extraGMM(no) drift(`drift') dfibudget(default) nD(`nD')
}
macro drop _all
log close


capture log close
log using MCcheckIVfulladd, replace text
*************************************************************************
* SUPPLY-PUSH IV WITH FULL ADDITIONALITY
*************************************************************************
foreach num of numlist 1/14 {
	local reps = 1000
	
	* local defaults
	local noise = 0.5
	local phi = 0
	local transition default
	local sigma = 0.15
	local drift = 0
	local dfilo = 0 
	local dfihi = 2
	local nD = 3
	
	
	/* 1 = default, noise 0.5 in pc: */
	if `num' == 1 {

	}
	/* 2 = fewertransitions, noise 0.5 in pc: */
	else if `num' == 2 {
		local transition fewertransitions
	}
	/* 3 = oneperiodchange, noise 0.5 in pc: */
	else if `num' == 3 {
		local transition oneperiodchange
	}
	/* 4 = fixedtypes, noise 0.5 in pc: */
	else if `num' == 4 {
		local transition fixedtypes
	}
	/* 5 = phi = 1, noise 0.5 in pc: */
	if `num' == 5 {
		local phi = 1
		local transition oneperiodchange
	}
	/* 6 = phi = 2, noise 0.5 in pc: */
	else if `num' == 6 {
		local phi = 2
		local transition oneperiodchange
	}
	/* 7 = sigma = 0.05, phi = 2, noise 0.5 in pc: */
	else if `num' == 7 {
		local sigma = 0.05
		local phi = 2
		local transition oneperiodchange
	}
	/* 8 = sigma = 0.05, phi = 2, noise 1 in pc: */
	else if `num' == 8 {
		local sigma = 0.05
		local phi = 2
		local noise = 1
		local transition oneperiodchange
	}
	/* 9 = default, noise 0.5 in pc, downward drift: */
	else if `num' == 9 {
		local transition default
		local sigma = 0
		local drift = -0.1
	}
	/* 10 = fewertransitions, noise 0.5 in pc, downward drift: */
	else if `num' == 10 {
		local transition fewertransitions
		local sigma = 0
		local drift = -0.1
	}
	/* 11 = fixedtypes, noise 0.5 in pc, downward drift: */
	else if `num' == 11 {
		local transition fixedtypes
		local sigma = 0
		local drift = -0.1
	}
	/* 12 = default, noise 0.5 in pc, upward drift: */
	else if `num' == 12 {
		local transition default
		local sigma = 0
		local drift = 0.05
	}
	/* 13 = fewertransitions, noise 0.5 in pc, upward drift: */
	else if `num' == 13 {
		local transition fewertransitions
		local sigma = 0
		local drift = 0.05
	}
	/* 14 = fixedtypes, noise 0.5 in pc, upward drift: */
	else if `num' == 14 {
		local transition fixedtypes
		local sigma = 0
		local drift = 0.05
	}
	
	simulate ivbetadfi=r(ivbetadfi) ivsedfi=r(ivsedfi) underid=r(underid) underidp=r(underidp) weakid=r(weakid) ///
	ivpzeroadd=r(ivpzeroadd) ivpfulladd=r(ivpfulladd) ivFSbeta=r(ivFSbeta) ivFSse=r(ivFSse) ivRFbeta=r(ivRFbeta) ivRFse=r(ivRFse) febetadfi=r(febetadfi) ///
	ivbetadfil1out=r(ivbetadfil1out) ivsedfil1out=r(ivsedfil1out) underidl1out=r(underidl1out) underidpl1out=r(underidpl1out) /// 
	weakidl1out=r(weakidl1out) ivpzeroaddl1out=r(ivpzeroaddl1out) ivpfulladdl1out=r(ivpfulladdl1out) ///
	ivbetadfict=r(ivbetadfict) ivsedfict=r(ivsedfict) underidct=r(underidct) underidpct=r(underidpct) weakidct=r(weakidct) ///
	ivpzeroaddct=r(ivpzeroaddct) ivpfulladdct=r(ivpfulladdct) ivFSbetact=r(ivFSbetact) ivFSsect=r(ivFSsect) ivRFbetact=r(ivRFbetact) ivRFsect=r(ivRFsect) ///
	ivpcbetadfi=r(ivpcbetadfi) ivpcsedfi=r(ivpcsedfi) underidpc=r(underidpc) underidppc=r(underidppc) weakidpc=r(weakidpc) ///
	ivpcpzeroadd=r(ivpcpzeroadd) ivpcpfulladd=r(ivpcpfulladd) ivpcFSbeta=r(ivpcFSbeta) ivpcFSse=r(ivpcFSse) ivpcRFbeta=r(ivpcRFbeta) ivpcRFse=r(ivpcRFse) fepcbetadfi=r(fepcbetadfi) ///
	ivpcbetadfil1out=r(ivpcbetadfil1out) ivpcsedfil1out=r(ivpcsedfil1out) underidpcl1out=r(underidpcl1out) underidppcl1out=r(underidppcl1out) /// 
	weakidpcl1out=r(weakidpcl1out) ivpcpzeroaddl1out=r(ivpcpzeroaddl1out) ivpcpfulladdl1out=r(ivpcpfulladdl1out) ///	
	ivbetadfitrue=r(ivbetadfitrue) ivbetanumprojerover2=r(ivbetanumprojerover2) covzu=r(covzu) covzx=r(covzx) /// 
	ivpcbetadfitrue=r(ivpcbetadfitrue) ivpcbetanumprojerover2=r(ivpcbetanumprojerover2) ivpcbetapctrue=r(ivpcbetapctrue) pccovzu=r(pccovzu) pccovzx=r(pccovzx) ///
	mindbpercnumprojerover2=r(mindbpercnumprojerover2) maxdbpercnumprojerover2=r(maxdbpercnumprojerover2) varz=r(varz) pcvarz=r(pcvarz) ///
	corrzu=r(corrzu) corrzx=r(corrzx) sdu=r(sdu) sdx=r(sdx) pccorrzu=r(pccorrzu) pccorrzx=r(pccorrzx) pcsdu=r(pcsdu) pcsdx=r(pcsdx) ///
	finaldb=r(finaldb) finalnumprojerover2=r(finalnumprojerover2) medinvDFIvsprivate=r(medinvDFIvsprivate) /// 
	type1invy1=r(type1invy1) type1invy20=r(type1invy20) type2invy1=r(type2invy1) type2invy20=r(type2invy20) type3invy1=r(type3invy1) type3invy20=r(type3invy20) ///
	type1dfiinvy1=r(type1dfiinvy1) type1dfiinvy20=r(type1dfiinvy20) type2dfiinvy1=r(type2dfiinvy1) type2dfiinvy20=r(type2dfiinvy20) type3dfiinvy1=r(type3dfiinvy1) type3dfiinvy20=r(type3dfiinvy20) ///
	type1dfiinvIVy1=r(type1dfiinvIVy1) type1dfiinvIVy20=r(type1dfiinvIVy20) type2dfiinvIVy1=r(type2dfiinvIVy1) type2dfiinvIVy20=r(type2dfiinvIVy20) type3dfiinvIVy1=r(type3dfiinvIVy1) type3dfiinvIVy20=r(type3dfiinvIVy20), /// 
	saving(./Generated data/IVfulladd`num'.dta, replace) reps(`reps') seed(150973): /// 
	elusive, noise(`noise') phi(`phi') estimator(IV) mechanism(random) transition(`transition') /// 
	sigma(`sigma') extraGMM(no) drift(`drift') dfilo(`dfilo') dfihi(`dfihi') dfibudget(default) nD(`nD')		
}
macro drop _all
log close


*************************************************************************
*************************************************************************
* NOW WITH CAPPED DFI BUDGET
*************************************************************************
*************************************************************************


capture log close
log using MCcheckOLSFEcapped, replace text
*************************************************************************
* OLS AND FIXED EFFECTS WITH CAPPED DFI BUDGET
*************************************************************************
* first 6: zero additionality.
foreach num of numlist 1/6 {
	local reps = 1000

	* initial value of parameters used here:
	local noise = 0
	local dfilo = 2
	local dfihi = 1000
	local psmin = 2
	local mechanism random
	local btot = 1

		
	/* 1 = starting point: zero additionality, random selection, no noise in pc: */
	if `num' == 1 {

	}
	/* 2 = zero additionality, random selection, noise 0.5: */
	else if `num' == 2 {
		local noise = 0.5
	}
	/* 3 = zero additionality, random selection, noise 1: */
	else if `num' == 3 {
		local noise = 1
	}
	/* 4 = zero additionality, pclow selection mechanism, no noise in pc: */
	else if `num' == 4 {
		local mechanism pclow
	}
	/* 5 = zero additionality, pclow selection mechanism, noise 0.5: */
	else if `num' == 5 {
		local mechanism pclow
		local noise = 0.5
	}
	/* 6 = zero additionality, pclow selection mechanism, noise 1: */
	else if `num' == 6 {
		local mechanism pclow
		local noise = 1
	}


	simulate olsbetadfi=r(olsbetadfi) olsr2=r(olsr2) olspzeroadd=r(olspzeroadd) olspfulladd=r(olspfulladd) /// 
	olspcbetadfi=r(olspcbetadfi) olspcr2=r(olspcr2) olspcpzeroadd=r(olspcpzeroadd) olspcpfulladd=r(olspcpfulladd) ///
	olspcnodfir2=r(olspcnodfir2) olspcnodfinotdummiesr2=r(olspcnodfinotdummiesr2) ///
	febetadfi=r(febetadfi) fewr2=r(fewr2) fepzeroadd=r(fepzeroadd) fepfulladd=r(fepfulladd) /// 
	fepcbetadfi=r(fepcbetadfi) fepcwr2=r(fepcwr2) fepcpzeroadd=r(fepcpzeroadd) fepcpfulladd=r(fepcpfulladd) ///
	fepcnodfiwr2=r(fepcnodfiwr2) fepcnodfinotdummieswr2=r(fepcnodfinotdummieswr2) ///
	olsbetadfitrue=r(olsbetadfitrue) olsbetanumprojerover2=r(olsbetanumprojerover2) olsdelta=r(olsdelta) olsdeltapartialledout=r(olsdeltapartialledout) ///
	olsdeltadenom=r(olsdeltadenom) olsdeltanum=r(olsdeltanum) covnumprojver2DFIinv=r(covnumprojver2DFIinv) varDFIinv=r(varDFIinv) ///
	olspcbetadfitrue=r(olspcbetadfitrue) olspcbetanumprojerover2=r(olspcbetanumprojerover2) olspcbetapctrue=r(olspcbetapctrue) olspcdelta=r(olspcdelta) /// 
	olspcdeltapartialledout=r(olspcdeltapartialledout) olspcdeltadenom=r(olspcdeltadenom) olspcdeltanum=r(olspcdeltanum) /// 
	maxdbpercnumprojerover2=r(maxdbpercnumprojerover2) medinvDFIvsprivate=r(medinvDFIvsprivate), /// 
	saving(./Generated data/OLSFEcapped`num'.dta, replace) reps(`reps') seed(150973): ///
	elusive, noise(`noise') mechanism(`mechanism') dfilo(`dfilo') dfihi(`dfihi') psmin(`psmin') estimator(OLSFE) transition(default) ///
	btot(`btot') extraGMM(no) dfibudget(capped)
	
}
macro drop _all
log close


capture log close
log using MCcheckGMMzeroaddcapped, replace text
*************************************************************************
* GMM WITH ZERO ADDITIONALITY WITH CAPPED DFI BUDGET
*************************************************************************
* Zero additionality, random selection mechanism
foreach num of numlist 1/6 {
	local reps = 1000

	*  initial values of parameters used here:
	local noise = 0
	local drift = 0
	local mu1 = 0
	local mu2 = 2
	local mu3 = 4
	local transition default
	local extraGMM yes
	local sigma = 0.15

	
	/* 1 = starting point, no noise: */
	if `num' == 1 {

	}
	/* 2 = noise = 0.5: */
	else if `num' == 2 {
		local noise = 0.5
	}
	/* 3 = noise = 1: */
	else if `num' == 3 {
		local noise = 1
	}
	/* 4 = : mean pc closer together, noise 0.5 */
	if `num' == 4 {
		local mu1 = 1
		local mu2 = 2
		local mu3 = 3
		local extraGMM no
		local noise = 0.5
	}
	/* 5 = mean pc the same, noise 0.5: */
	if `num' == 5 {
		local mu1 = 2
		local mu2 = 2
		local mu3 = 2
		local extraGMM no
		local noise = 0.5
	}
	/* 6 = types fixed, noise 0.5: */
	if `num' == 6 {
		local transition fixedtypes
		local extraGMM no
		local noise = 0.5
	}

	
	simulate betadfi1=r(betadfi1) numinstr1=r(numinstr1) m1p1=r(m1p1) m11=r(m11) m2p1=r(m2p1) ///
	hansp1=r(hansp1) sargp1=r(sargp1) /// 
	pzeroadd1=r(pzeroadd1) pfulladd1=r(pfulladd1) condFDFI1=r(condFDFI1) condFDFIp1=r(condFDFIp1) ///
	betadfiwpc1=r(betadfiwpc1) numinstrwpc1=r(numinstrwpc1) m1pwpc1=r(m1pwpc1) m1wpc1=r(m1wpc1) m2pwpc1=r(m2pwpc1) ///
	hanspwpc1=r(hanspwpc1) sargpwpc1=r(sargpwpc1) diffHp_DFIinvdiffwpc1=r(diffHp_DFIinvdiffwpc1) diffHp_DFIinvlevwpc1=r(diffHp_DFIinvlevwpc1) /// 
	pzeroaddwpc1=r(pzeroaddwpc1) pfulladdwpc1=r(pfulladdwpc1) condFDFIwpc1=r(condFDFIwpc1) condFDFIpwpc1=r(condFDFIpwpc1) ///
	betadfi2=r(betadfi2) betalagdep2=r(betalagdep2) numinstr2=r(numinstr2) m1p2=r(m1p2) m12=r(m12) m2p2=r(m2p2) ///
	hansp2=r(hansp2) sargp2=r(sargp2) ///
	diffHp_DFIinvdiff2=r(diffHp_DFIinvdiff2) diffHp_DFIinvlev2=r(diffHp_DFIinvlev2) /// 
	pzeroadd2=r(pzeroadd2) pfulladd2=r(pfulladd2) condFDFI2=r(condFDFI2) condFDFIp2=r(condFDFIp2) ///
	betadfiwpc2=r(betadfiwpc2) betalagdepwpc2=r(betalagdepwpc2) numinstrwpc2=r(numinstrwpc2) m1pwpc2=r(m1pwpc2) m1wpc2=r(m1wpc2) m2pwpc2=r(m2pwpc2) ///
	hanspwpc2=r(hanspwpc2) sargpwpc2=r(sargpwpc2) ///
	diffHp_lagdepwpc2=r(diffHp_lagdepwpc2) diffHp_DFIinvdiffwpc2=r(diffHp_DFIinvdiffwpc2) diffHp_DFIinvlevwpc2=r(diffHp_DFIinvlevwpc2) diffHp_pc2=r(diffHp_pc2) /// 
	pzeroaddwpc2=r(pzeroaddwpc2) pfulladdwpc2=r(pfulladdwpc2) condFDFIwpc2=r(condFDFIwpc2) condFDFIpwpc2=r(condFDFIpwpc2) ///
	betadfi3=r(betadfi3) numinstr3=r(numinstr3) m1p3=r(m1p3) m13=r(m13) m2p3=r(m2p3) ///
	hansp3=r(hansp3) sargp3=r(sargp3) diffHp_lev3=r(diffHp_lev3) diffHp_DFIinvlev3=r(diffHp_DFIinvlev3) /// 
	pzeroadd3=r(pzeroadd3) pfulladd3=r(pfulladd3) condFDFI3=r(condFDFI3) condFDFIp3=r(condFDFIp3) ///
	betadfiwpc3=r(betadfiwpc3) numinstrwpc3=r(numinstrwpc3) m1pwpc3=r(m1pwpc3) m1wpc3=r(m1wpc3) m2pwpc3=r(m2pwpc3) ///
	hanspwpc3=r(hanspwpc3) sargpwpc3=r(sargpwpc3) diffHp_levwpc3=r(diffHp_levwpc3) diffHp_DFIinvdiffwpc3=r(diffHp_DFIinvdiffwpc3) ///
	diffHp_DFIinvlevwpc3=r(diffHp_DFIinvlevwpc3) diffHp_pc3=r(diffHp_pc3) ///
	pzeroaddwpc3=r(pzeroaddwpc3) pfulladdwpc3=r(pfulladdwpc3) condFDFIwpc3=r(condFDFIwpc3) condFDFIpwpc3=r(condFDFIpwpc3) ///
	betadfi4=r(betadfi4) betalagdep4=r(betalagdep4) numinstr4=r(numinstr4) m1p4=r(m1p4) m14=r(m14) m2p4=r(m2p4) ///
	hansp4=r(hansp4) sargp4=r(sargp4) diffHp_lev4=r(diffHp_lev4) diffHp_lagdep4=r(diffHp_lagdep4) ///
	diffHp_DFIinvdiff4=r(diffHp_DFIinvdiff4) diffHp_DFIinvlev4=r(diffHp_DFIinvlev4) /// 
	pzeroadd4=r(pzeroadd4) pfulladd4=r(pfulladd4) condFDFI4=r(condFDFI4) condFDFIp4=r(condFDFIp4) ///
	betadfiwpc4=r(betadfiwpc4) betalagdepwpc4=r(betalagdepwpc4) numinstrwpc4=r(numinstrwpc4) m1pwpc4=r(m1pwpc4) m1wpc4=r(m1wpc4) m2pwpc4=r(m2pwpc4) ///
	hanspwpc4=r(hanspwpc4) sargpwpc4=r(sargpwpc4) diffHp_levwpc4=r(diffHp_levwpc4) diffHp_lagdepwpc4=r(diffHp_lagdepwpc4) ///
	diffHp_DFIinvdiffwpc4=r(diffHp_DFIinvdiffwpc4) diffHp_DFIinvlevwpc4=r(diffHp_DFIinvlevwpc4) diffHp_pc4=r(diffHp_pc4) /// 
	pzeroaddwpc4=r(pzeroaddwpc4) pfulladdwpc4=r(pfulladdwpc4) condFDFIwpc4=r(condFDFIwpc4) condFDFIpwpc4=r(condFDFIpwpc4) ///
	betadfi5=r(betadfi5) numinstr5=r(numinstr5) m1p5=r(m1p5) m15=r(m15) m2p5=r(m2p5) ///
	pzeroadd5=r(pzeroadd5) pfulladd5=r(pfulladd5) condFDFI5=r(condFDFI5) condFDFIp5=r(condFDFIp5) ///
	betadfiwpc5=r(betadfiwpc5) numinstrwpc5=r(numinstrwpc5) m1pwpc5=r(m1pwpc5) m1wpc5=r(m1wpc5) m2pwpc5=r(m2pwpc5) ///
	pzeroaddwpc5=r(pzeroaddwpc5) pfulladdwpc5=r(pfulladdwpc5) condFDFIwpc5=r(condFDFIwpc5) condFDFIpwpc5=r(condFDFIpwpc5) ///
	betadfi6=r(betadfi6) pzeroadd6=r(pzeroadd6) pfulladd6=r(pfulladd6) FSrobustF6=r(FSrobustF6) FSbetaL2DFI6=r(FSbetaL2DFI6) OVbetaL2DFI6=r(OVbetaL2DFI6) ///
	corrL2DFIu6=r(corrL2DFIu6) corrL2DFIx6=r(corrL2DFIx6) ///
	sdu6=r(sdu6) sdx6=r(sdx6) ///
	betadfiwpc6=r(betadfiwpc6) pzeroaddwpc6=r(pzeroaddwpc6) pfulladdwpc6=r(pfulladdwpc6) FSrobustFwpc6=r(FSrobustFwpc6) FSbetaL2DFIwpc6=r(FSbetaL2DFIwpc6) FSbetaL2pc6=r(FSbetaL2pc6) ///
	OVbetaL2DFIwpc6=r(OVbetaL2DFIwpc6) OVbetaL2pc6=r(OVbetaL2pc6) ///
	betadfi7=r(betadfi7) numinstr7=r(numinstr7) m1p7=r(m1p7) m17=r(m17) m2p7=r(m2p7) ///
	pzeroadd7=r(pzeroadd7) pfulladd7=r(pfulladd7) condFDFI7=r(condFDFI7) condFDFIp7=r(condFDFIp7) ///
	betadfiwpc7=r(betadfiwpc7) numinstrwpc7=r(numinstrwpc7) m1pwpc7=r(m1pwpc7) m1wpc7=r(m1wpc7) m2pwpc7=r(m2pwpc7) ///
	pzeroaddwpc7=r(pzeroaddwpc7) pfulladdwpc7=r(pfulladdwpc7) condFDFIwpc7=r(condFDFIwpc7) condFDFIpwpc7=r(condFDFIpwpc7) ///
	betadfi8=r(betadfi8) pzeroadd8=r(pzeroadd8) pfulladd8=r(pfulladd8) FSrobustF8=r(FSrobustF8) FSbetaDLDFI8=r(FSbetaDLDFI8) OVbetaDLDFI8=r(OVbetaDLDFI8) ///
	corrDLDFIu8=r(corrDLDFIu8) corrDLDFIx8=r(corrDLDFIx8) ///
	sdu8=r(sdu8) sdx8=r(sdx8) ///
	betadfiwpc8=r(betadfiwpc8) pzeroaddwpc8=r(pzeroaddwpc8) pfulladdwpc8=r(pfulladdwpc8) FSrobustFwpc8=r(FSrobustFwpc8) FSbetaDLDFIwpc8=r(FSbetaDLDFIwpc8) FSbetaDLpc8=r(FSbetaDLpc8) ///
	OVbetaDLDFIwpc8=r(OVbetaDLDFIwpc8) OVbetaDLpc8=r(OVbetaDLpc8) ///	
	maxdbpercnumprojerover2=r(maxdbpercnumprojerover2) finaldb=r(finaldb) finalnumprojerover2=r(finalnumprojerover2) medinvDFIvsprivate=r(medinvDFIvsprivate) ///
	, saving(./Generated data/GMMzeroaddcapped`num'.dta, replace) reps(`reps') seed(150973): elusive, noise(`noise') estimator(GMM) mechanism(random) transition(`transition') ///
	drift(`drift') mu1(`mu1') mu2(`mu2') mu3(`mu3') extraGMM(`extraGMM') sigma(`sigma') dfibudget(capped)
}
macro drop _all
log close


capture log close
log using MCcheckIVzeroaddcapped, replace text
*************************************************************************
* SUPPLY-PUSH IV WITH ZERO ADDITIONALITY WITH DFI CAPPED
*************************************************************************
foreach num of numlist 1/8 {
	local reps = 1000
	
	* local defaults
	local noise = 0.5
	local phi = 0
	local transition default
	local sigma = 0.15
	local drift = 0
	local nD = 3

	
	/* 1 = default, noise 0.5 in pc: */
	if `num' == 1 {

	}
	/* 2 = fewertransitions, noise 0.5 in pc: */
	else if `num' == 2 {
		local transition fewertransitions
	}
	/* 3 = oneperiodchange, noise 0.5 in pc: */
	else if `num' == 3 {
		local transition oneperiodchange
	}
	/* 4 = fixedtypes, noise 0.5 in pc: */
	else if `num' == 4 {
		local transition fixedtypes
	}
	/* 5 = phi = 1, noise 0.5 in pc: */
	if `num' == 5 {
		local phi = 1
		local transition oneperiodchange
	}
	/* 6 = phi = 2, noise 0.5 in pc: */
	else if `num' == 6 {
		local phi = 2
		local transition oneperiodchange
	}
	/* 7 = sigma = 0.05, phi = 2, noise 0.5 in pc: */
	else if `num' == 7 {
		local sigma = 0.05
		local phi = 2
		local transition oneperiodchange
	}
	/* 8 = sigma = 0.05, phi = 2, noise 1 in pc: */
	else if `num' == 8 {
		local sigma = 0.05
		local phi = 2
		local noise = 1
		local transition oneperiodchange
	}
	
	simulate ivbetadfi=r(ivbetadfi) ivsedfi=r(ivsedfi) underid=r(underid) underidp=r(underidp) weakid=r(weakid) ///
	ivpzeroadd=r(ivpzeroadd) ivpfulladd=r(ivpfulladd) ivFSbeta=r(ivFSbeta) ivFSse=r(ivFSse) ivRFbeta=r(ivRFbeta) ivRFse=r(ivRFse) febetadfi=r(febetadfi) ///
	ivbetadfil1out=r(ivbetadfil1out) ivsedfil1out=r(ivsedfil1out) underidl1out=r(underidl1out) underidpl1out=r(underidpl1out) /// 
	weakidl1out=r(weakidl1out) ivpzeroaddl1out=r(ivpzeroaddl1out) ivpfulladdl1out=r(ivpfulladdl1out) ///
	ivbetadfict=r(ivbetadfict) ivsedfict=r(ivsedfict) underidct=r(underidct) underidpct=r(underidpct) weakidct=r(weakidct) ///
	ivpzeroaddct=r(ivpzeroaddct) ivpfulladdct=r(ivpfulladdct) ivFSbetact=r(ivFSbetact) ivFSsect=r(ivFSsect) ivRFbetact=r(ivRFbetact) ivRFsect=r(ivRFsect) ///
	ivpcbetadfi=r(ivpcbetadfi) ivpcsedfi=r(ivpcsedfi) underidpc=r(underidpc) underidppc=r(underidppc) weakidpc=r(weakidpc) ///
	ivpcpzeroadd=r(ivpcpzeroadd) ivpcpfulladd=r(ivpcpfulladd) ivpcFSbeta=r(ivpcFSbeta) ivpcFSse=r(ivpcFSse) ivpcRFbeta=r(ivpcRFbeta) ivpcRFse=r(ivpcRFse) fepcbetadfi=r(fepcbetadfi) ///
	ivpcbetadfil1out=r(ivpcbetadfil1out) ivpcsedfil1out=r(ivpcsedfil1out) underidpcl1out=r(underidpcl1out) underidppcl1out=r(underidppcl1out) /// 
	weakidpcl1out=r(weakidpcl1out) ivpcpzeroaddl1out=r(ivpcpzeroaddl1out) ivpcpfulladdl1out=r(ivpcpfulladdl1out) ///	
	ivbetadfitrue=r(ivbetadfitrue) ivbetanumprojerover2=r(ivbetanumprojerover2) covzu=r(covzu) covzx=r(covzx) /// 
	ivpcbetadfitrue=r(ivpcbetadfitrue) ivpcbetanumprojerover2=r(ivpcbetanumprojerover2) ivpcbetapctrue=r(ivpcbetapctrue) pccovzu=r(pccovzu) pccovzx=r(pccovzx) ///
	mindbpercnumprojerover2=r(mindbpercnumprojerover2) maxdbpercnumprojerover2=r(maxdbpercnumprojerover2) varz=r(varz) pcvarz=r(pcvarz) ///
	corrzu=r(corrzu) corrzx=r(corrzx) sdu=r(sdu) sdx=r(sdx) pccorrzu=r(pccorrzu) pccorrzx=r(pccorrzx) pcsdu=r(pcsdu) pcsdx=r(pcsdx) ///
	finaldb=r(finaldb) finalnumprojerover2=r(finalnumprojerover2) medinvDFIvsprivate=r(medinvDFIvsprivate) /// 
	type1invy1=r(type1invy1) type1invy20=r(type1invy20) type2invy1=r(type2invy1) type2invy20=r(type2invy20) type3invy1=r(type3invy1) type3invy20=r(type3invy20) ///
	type1dfiinvy1=r(type1dfiinvy1) type1dfiinvy20=r(type1dfiinvy20) type2dfiinvy1=r(type2dfiinvy1) type2dfiinvy20=r(type2dfiinvy20) type3dfiinvy1=r(type3dfiinvy1) type3dfiinvy20=r(type3dfiinvy20) ///
	type1dfiinvIVy1=r(type1dfiinvIVy1) type1dfiinvIVy20=r(type1dfiinvIVy20) type2dfiinvIVy1=r(type2dfiinvIVy1) type2dfiinvIVy20=r(type2dfiinvIVy20) type3dfiinvIVy1=r(type3dfiinvIVy1) type3dfiinvIVy20=r(type3dfiinvIVy20), /// 
	saving(./Generated data/IVzeroaddcapped`num'.dta, replace) reps(`reps') seed(150973): /// 
	elusive, noise(`noise') phi(`phi') estimator(IV) mechanism(random) transition(`transition') /// 
	sigma(`sigma') extraGMM(no) drift(`drift') dfibudget(capped) nD(`nD')
}
macro drop _all
log close
